package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.domain.db.SoulOptions;
import com.tanhua.dubbo.api.db.SoulOptionsApi;
import com.tanhua.dubbo.mapper.SoulOptionsMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class SoulOptionsApiImpl implements SoulOptionsApi {

    @Autowired
    private SoulOptionsMapper soulOptionsMapper;

    @Override
    public List<SoulOptions> queryOptions(String questionId) {
        QueryWrapper<SoulOptions> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(SoulOptions::getQuestionId,questionId);
        List<SoulOptions> optionsList = soulOptionsMapper.selectList(wrapper);
        return optionsList;


    }

    @Override
    public String queryScore(String questionId, String optionId) {
        QueryWrapper<SoulOptions> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(SoulOptions::getId,optionId);
        wrapper.lambda().eq(SoulOptions::getQuestionId,questionId);
        SoulOptions soulOptions = soulOptionsMapper.selectOne(wrapper);
        return soulOptions.getScore();
    }
}
